//
//  NSString+BYSAsistant.m
//  OrangeCard
//  Created by tianXin on 16/9/1..
//

#import "NSString+BYSAsistant.h"

@implementation NSString (BYSAsistant)

- (NSString *)logString    //对字符串中汉字显示乱码的处理
{
    NSString *tempStr1 = [self stringByReplacingOccurrencesOfString:@"\\u" withString:@"\\U"];
    NSString *tempStr2 = [tempStr1 stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
    NSString *tempStr3 = [[@"\"" stringByAppendingString:tempStr2] stringByAppendingString:@"\""];
    NSData *tempData = [tempStr3 dataUsingEncoding:NSUTF8StringEncoding];
    NSString *str = [NSPropertyListSerialization propertyListFromData:tempData mutabilityOption:NSPropertyListImmutable format:NULL errorDescription:NULL];
    return str;
}


+ (NSString *)stringFromDate:(NSDate *)date{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    //zzz表示时区，zzz可以删除，这样返回的日期字符将不包含时区信息。
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    NSString *destDateString = [dateFormatter stringFromDate:date];
    return destDateString;
}

+ (NSString *)timeStringFromDate:(NSDate *)date{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    //zzz表示时区，zzz可以删除，这样返回的日期字符将不包含时区信息。
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString *destDateString = [dateFormatter stringFromDate:date];
    return destDateString;
}

+ (NSString *)makeMutiLineString:(NSArray *)strArray{
    NSMutableString *mStr = [[NSMutableString alloc] init];
    for (int i=0; i<[strArray count]; i++) {
        NSString *str = [strArray objectAtIndex:i];
        [mStr appendString:str];
        if (i<[strArray count]-1) {
            [mStr appendString:@"\r\n"];
        }
    }
    return mStr;
}

+ (NSString *)stringWithEncodingString:(NSString *)string{
    NSString  *dataString = [[NSString alloc] initWithData:[string dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES] encoding:NSASCIIStringEncoding];
    NSString *str = [dataString stringByReplacingOccurrencesOfString:@" " withString:@""];
    return str;
}
//
//- (id)filtNilParamater{
//    if ([self isBlank]) {
//        return nil;
//    }else{
//        return self;
//    }
//}

@end
